function gcd(a,b:longint; var x,y:longint):longint;

var
	x1,y1,d:longint;

begin
if a = 0 then begin
	x := 0;
	y := 1;
	result := b;
	exit;
end;
x1 := 0;
y1 := 0;
d := gcd(b mod a, a, x1, y1);
x := y1 - (b div a) * x1;
y := x1;
result := d;
end;

procedure solve(a,b,c:longint; var x,y:longint); // in case of NO SOLUTION returns x = 0, y = 0

var
	g:longint;
	
begin
if (a = 0) and (b = 0) then begin
	x := 0;
	y := 0;
	exit;
end;
if a = 0 then begin
	x := 0;
	y := c div b;
	exit;
end;
if b = 0 then begin
	x := c div a;
	y := 0;
	exit;
end;
g := gcd(a, b, x, y);
if c mod g = 0 then begin
	x := x * (c div g);
	y := y * (c div g);
end else begin
	x := 0;
	y := 0;
end;
end;